<!--公共bar-->
<template>
  <van-sticky>
    <!--头部bar开始-->
    <p class="titlebar">
      <span @click="goback()">
        <van-icon name="arrow-left" size="18" v-if="options.lefttype='left' " />
      </span>
      <span>{{options.centerText}}</span>
      <span>
        {{options.rightText}}
        <van-icon :name="options.iconNname" size="18" v-if="options.type='icon'" @click="toHome" />
      </span>
    </p>
    <!--头部bar结束-->
  </van-sticky>
</template>
<script>
export default {
  props: {
    options: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      centerText: "",
      rightText: ""
    };
  },
  methods: {
    goback() {
      if (this.$route.path == "/checkIndex") {
        this.$router.push({
          //核心语句
          path: "/home" //跳转的路径
        });
      } else if (this.$route.path == "/approveIndex") {
        this.$router.push({
          //核心语句
          path: "/home" //跳转的路径
        });
      } else {
        this.$router.go(-1);
      }
    },

    toHome() {
      this.$router.push({
        //核心语句
        path: "/home" //跳转的路径
      });
    }
  }
};
</script>
<style lang="less" scoped>
.titlebar {
  width: 100%;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 18px;
  font-family: Source Han Sans CN;
  font-weight: 400;
  color: rgba(255, 255, 255, 1);
  background: linear-gradient(
    -50deg,
    rgba(10, 213, 145, 1) 0%,
    rgba(10, 213, 145, 1) 100%
  );
  margin: 0;
  padding: 0 15px;
  box-sizing: border-box;
  .van-icon {
    vertical-align: middle;
  }
}
</style>